<template>
	<view>
		<view v-if="collect!=''">
			<view class="guess-section">
				<view v-for="(item, index) in collect" :key="index" class="guess-item" @click="navToDetailPage(item)">
					<view class="image-wrapper">
						<image :src="item.img" mode="aspectFill"></image>
					</view>
					<text class="title clamp">{{item.title}}</text>
					<text class="price">￥{{item.price}}</text>
				</view>
			</view>
		</view>
		<view v-else>暂无收藏商品</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				collect: '',
			}
		},
		onLoad() {
			this.$corpid = uni.getStorageSync('corpid');
			this.loadData();
		},
		methods: {

			loadData() {
				this.$util.util('MemberBill/CollectionList', {
					corpid: this.$corpid
				}, 'POST').then(res => {
					console.log(res);
					if (res.list == null) {
						this.collect = '';
					} else {
						this.collect = res.list;
					}

				})
			},
			//详情页
			navToDetailPage(item){
				let id = '0',
					acytpe = '',
					goodsid = item.id||item.FItemID;
				uni.navigateTo({
					url: `/pages/product/product?id=${id}&actype=${acytpe}&goodsid=${goodsid}`
				})
			},
		}
	}
</script>

<style lang="scss">
	.guess-section {
		display: flex;
		flex-wrap: wrap;
		padding: 0 30upx;
		background: #fff;

		.guess-item {
			display: flex;
			flex-direction: column;
			width: 48%;
			padding-bottom: 40upx;

			&:nth-child(2n+1) {
				margin-right: 4%;
			}
		}

		.image-wrapper {
			width: 100%;
			height: 330upx;
			border-radius: 3px;
			overflow: hidden;

			image {
				width: 100%;
				height: 100%;
				opacity: 1;
			}
		}

		.title {
			font-size: $font-lg;
			color: $font-color-dark;
			line-height: 80upx;
		}

		.price {
			font-size: $font-lg;
			color: $uni-color-primary;
			line-height: 1;
		}
	}
</style>
